import * as React from "react"
import { inject, observer } from 'mobx-react'
import { CompanyStore } from './store'

@inject('companyStore')
@observer
export default class Company extends React.Component<{ companyStore?: CompanyStore }> {

	componentDidMount() {
		console.log('componentDidMount')
		console.log(this.props.companyStore)
	}

	componentWillUnmount() {
		// console.log('componentWillUnmount')
	}

	changeName = (name: string): void => {
		let { changeName } = this.props.companyStore!
		changeName(name)
	}

	render() {
		let { name, sex, nameLength } = this.props.companyStore!
		return (
			<div>
				{name}-{sex}-{nameLength}
				<button onClick={this.changeName.bind(this, '张三222')}>修改姓名</button>
			</div>
		)
	}
}
